﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Biz_Dal.Biz;

public partial class The_hien_TH_TIM_KIEM_NANG_CAO : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<BizTheLoai> theLoai = new List<BizTheLoai>();
            theLoai = BizTheLoai.getListTheLoaiAll();
            DropDownListTheLoai.DataSource = theLoai;
            DropDownListTheLoai.DataTextField = "tenTheLoai";
            DropDownListTheLoai.DataValueField = "idTheLoai";
            DropDownListTheLoai.DataBind();
            DropDownListTheLoai.Items.Insert(0, new ListItem("Tất cả", "-1"));
            DropDownListTheLoai.SelectedIndex = 0;

            List<BizNXB> nxb = new List<BizNXB>();
            nxb = BizNXB.getListNXBAll();
            DropDownListNXB.DataSource = nxb;
            DropDownListNXB.DataTextField = "tenNXB";
            DropDownListNXB.DataValueField = "idNXB";
            DropDownListNXB.DataBind();
            DropDownListNXB.Items.Insert(0, new ListItem("Tất cả", "-1"));
            DropDownListNXB.SelectedIndex = 0;

        }
    }
    protected void btnTim_Click(object sender, EventArgs e)
    {
        string tenS = txtTenSach.Text;
        string idTL = DropDownListTheLoai.SelectedValue;
        string idNXB = DropDownListNXB.SelectedValue;
        
        string giaBD = txtGiaBD.Text.Trim();
        string giaKT = txtGiaKT.Text.Trim();

        try
        {
            int bd = int.Parse(giaBD);
        }
        catch
        {
            giaBD = "-1";
        }
        try
        {
            int kt = int.Parse(giaKT);
        }
        catch
        {
            giaKT = "-1";
        }

        Response.Redirect("~/Trang_web/Trang_tim_kiem.aspx?TimKiem=2&Ten_sach=" +
                            tenS+"&IDTL="+idTL+"&IDNXB="+idNXB+"&GiaBD="+giaBD+
                            "&GiaKT="+giaKT);

    }
}